var _tools = require("../../../utils/tools.js"), _tools2 = _interopRequireDefault(_tools);

function _interopRequireDefault(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}

var that, app = getApp();
let interstitialAd = null;

function a(o) {
    var t = {
        action: "participant",
        contr: "luck",
        token: wx.getStorageSync("token"),
        id: o.data.id,
        p: o.data.p
    };
    _tools2.default.request(t, function(t) {
        var a = t.info.user;
        1 < o.data.p && (a = o.data.user.concat(a)), t.info.user.length < 100 && o.setData({
            showstate: !0
        }), o.setData({
            user: a
        }), o.hw();
    });
}

Page({
    data: {
        picHeight: "Hello World",
        userInfo: {},
        showstate: !1,
        id: 0,
        user: [],
        p: 1
    },
    onReady: function() {
        wx.setNavigationBarColor({
            frontColor: "#000000",
            backgroundColor: "#000000"
        });
    },
    onShow: function() {
        if (wx.createInterstitialAd) {
            interstitialAd = wx.createInterstitialAd({
              adUnitId: 'adunit-42e141bfcfdcc315'
            })
            interstitialAd.onLoad(() => {})
            interstitialAd.onError((err) => {})
            interstitialAd.onClose(() => {})
          };
          
          // 在适合的场景显示插屏广告
          if (interstitialAd) {
            interstitialAd.show().catch((err) => {
              console.error(err)
            })
          };
    },
    onLoad: function(t) {
        (that = this).data.id = t.id;
        var o = {
            action: "pLoad",
            contr: "luck",
            token: wx.getStorageSync("token"),
            id: this.data.id
        };
        _tools2.default.request(o, function(t) {
            that.setData(t.info);
        }), a(that);
    },
    gotodrawLottery: function() {
        wx.navigateTo({
            url: "/pages/drawLottery/drawLottery"
        });
    },
    hw: function() {
        wx.createSelectorQuery().select(".user-avatar").boundingClientRect(function(t) {
            that.setData({
                picHeight: t.width
            });
        }).exec();
    },
    loadmore: function() {
        console.log(this.data), this.data.showstate || (this.data.p++, a(this));
    }
});